package cn.rui.controller;

import cn.rui.aspects.Log;
import cn.rui.common.Result;
import cn.rui.pojo.Permission;
import cn.rui.service.PermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 权限
 * @author 徽州大都督
 * @date 2021/05/14
 */
@RestController
@RequestMapping("permission")
public class PermissionController {

    @Autowired
    private PermissionService permissionService;

    @GetMapping("findPermissionUserUUid/{uuid}")
    public Result findPermissionUserUUid(@PathVariable("uuid") String uuid){
        List<Integer> permissionList = permissionService.findByUserUuids (uuid);

        return Result.getSuccess ("查询权限成功",permissionList);
    }

    @GetMapping("findPermission")
    public Result findPermission(){
        List<Permission> permissionList = permissionService.findPermission ();

        return Result.getSuccess ("查询权限成功",permissionList);
    }


    @PutMapping("editPermissionByUUid/{permissionIds}/{uuid}")
    @Log("修改权限")
    public Result editPermissionByUUid(@PathVariable("permissionIds")List<Integer> permissionIds, @PathVariable("uuid") String uuid){
        return permissionService.editPermissionByUUid(permissionIds,uuid);
    }
}
